﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using KeaoBase;
using DataCenter_DataBase;
using System.Data;
using System.Text;
using System.Threading;

namespace DataCenter.Models.WeiXin
{
    public class WeiXinEvent_CLICK:BaseWeiXinEvent
    {
        private ApiDataBase m_Api;
        public WeiXinEvent_CLICK(KeaoXmlHelper XmlHelper) : base(XmlHelper)
        {
            this.EventKey = XmlHelper.GetFirstNodeInnerString("EventKey");
            m_Api = new ApiDataBase();
        }
        public string EventKey { get; set; }

        public override string ResponseResult()
        {
            tbl_weixin_user item = m_Api.GetWeiXinUserByOpenId(FromUserName);
            if (item != null)
            {
                if (item.user_status==0||string.IsNullOrEmpty(item.client_code)||item.expires_time <= DateTime.Today)
                {
                    return ReturnTextMsg("您好，您的授权已失效。");
                }
                tbl_client clientItem = m_Api.GetClientByCode(item.client_code);
                if (clientItem == null)
                {
                    return ReturnTextMsg("您好，没有找到客户信息，请稍后重试。");
                }
                else
                {
                    BaseDataBase m_DB = System.Reflection.Assembly.Load("KeaoDataBase").CreateInstance(string.Format("KeaoDataBase.{0}", clientItem.datasource_type)) as BaseDataBase;
                    if (m_DB.InitDataBase(clientItem.datasource_string))
                    {
                        switch (this.EventKey)
                        {
                            case "10":
                                return ReturnTextMsg(Event10Handler(m_DB));
                            case "11":
                                return ReturnTextMsg(Event11Handler(m_DB));
                            case "12":
                                return ReturnTextMsg(Event12Handler(m_DB));
                            case "13":
                                return ReturnTextMsg(Event13Handler(m_DB));
                            case "20":
                                return ReturnTextMsg(Event20Handler(m_DB));
                            case "21":
                                return ReturnTextMsg(Event21Handler(m_DB));
                            case "22":
                                return ReturnTextMsg(Event22Handler(m_DB));
                            case "31":
                                return ReturnTextMsg(Event31Handler(m_DB));
                            case "32":
                                return ReturnTextMsg(Event32Handler(m_DB));
                            default:
                                return ReturnTextMsg("您好，服务正在研发中，敬请期待。");
                        }
                    }
                    else
                    {
                        return ReturnTextMsg("您好，服务暂不可用，请稍后重试。");
                    }
                }
            }
            else
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(WeiXinComm.CreateWeiXinUser), this);
                return ReturnTextMsg("您好，已为您创建关联账户。\n请联系【科奥电子】获取授权。");
            }

        }

        public string Event10Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "入库物料", "", SearchConditionType.等于);
                DateTime kaiShiDate = DateTime.Today.AddDays(-1);
                DateTime jieShuDate = kaiShiDate.AddHours(23).AddMinutes(59).AddSeconds(59);
                createCondition += m_DB.CreateAndCondition("pizhongshijian", DataValueCommonType.日期时间, kaiShiDate.ToString("yyyy-MM-dd HH:mm:ss"), jieShuDate.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "wuliaomingcheng,xinghao,zhandian,count(id) as cheshu,sum(maozhong) as maozhong,sum(pizhong) as pizhong,sum(kouzhong) as kouzhong,sum(jingzhong) as jingzhong,sum(fahuozhongliang) as fahuozhongliang,sum(jisuanfangliang) as jisuanfangliang";
                groupCols = "wuliaomingcheng,xinghao,zhandian";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}入库日统计】\n", kaiShiDate.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }

            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("今日入库异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event11Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "入库物料", "", SearchConditionType.等于);
                DateTime kaiShiDate = DateTime.Today;
                DateTime jieShuDate = kaiShiDate.AddHours(23).AddMinutes(59).AddSeconds(59);
                createCondition += m_DB.CreateAndCondition("pizhongshijian", DataValueCommonType.日期时间, kaiShiDate.ToString("yyyy-MM-dd HH:mm:ss"), jieShuDate.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "wuliaomingcheng,xinghao,zhandian,count(id) as cheshu,sum(maozhong) as maozhong,sum(pizhong) as pizhong,sum(kouzhong) as kouzhong,sum(jingzhong) as jingzhong,sum(fahuozhongliang) as fahuozhongliang,sum(jisuanfangliang) as jisuanfangliang";
                groupCols = "wuliaomingcheng,xinghao,zhandian";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}入库日统计】\n", kaiShiDate.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }
             
            }
            catch(Exception err)
            {
                KeaoUtils.LogTxt(string.Format("今日入库异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event12Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "入库物料", "", SearchConditionType.等于);
                DateTime today = DateTime.Today;
                DateTime kaiShiDate = new DateTime(today.Year, today.Month, 1);
                DateTime jieShuDate = today.AddHours(23).AddMinutes(59).AddSeconds(59);
                createCondition += m_DB.CreateAndCondition("pizhongshijian", DataValueCommonType.日期时间, kaiShiDate.ToString("yyyy-MM-dd HH:mm:ss"), jieShuDate.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "wuliaomingcheng,xinghao,zhandian,count(id) as cheshu,sum(maozhong) as maozhong,sum(pizhong) as pizhong,sum(kouzhong) as kouzhong,sum(jingzhong) as jingzhong,sum(fahuozhongliang) as fahuozhongliang,sum(jisuanfangliang) as jisuanfangliang";
                groupCols = "wuliaomingcheng,xinghao,zhandian";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}入库月统计】\n", kaiShiDate.ToString("yyyy-MM")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }

            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("本月入库异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event13Handler(BaseDataBase m_DB)
        {
            try
            {
                DateTime curDate = DateTime.Today.AddDays(-1);
                string createCondition = m_DB.CreateAndCondition("riqi", DataValueCommonType.日期时间,curDate.ToString("yyyy-MM-dd HH:mm:ss"), "", SearchConditionType.等于);
                createCondition += m_DB.CreateAndCondition("kucun", DataValueCommonType.数字,"0" ,"", SearchConditionType.大于);
                string tableCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "zhandian,wuliaomingcheng,xinghaomingcheng,kucun";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_kucun", tableCols, null, createCondition, null, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【截止{0}库存】\n", curDate.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghaomingcheng"], row["kucun"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghaomingcheng"], row["kucun"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    strBuilder.Append("本查询结果，基于系统自动计算账面库存，为保证准确性，请正确维护账面库存数据。");
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }

            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("库存查询异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event20Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "出库物料", "", SearchConditionType.等于);
                DateTime kaiShiDate = DateTime.Today.AddDays(-1);
                DateTime jieShuDate = kaiShiDate.AddHours(23).AddMinutes(59).AddSeconds(59);
                createCondition += m_DB.CreateAndCondition("maozhongshijian", DataValueCommonType.日期时间, kaiShiDate.ToString("yyyy-MM-dd HH:mm:ss"), jieShuDate.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "wuliaomingcheng,xinghao,zhandian,count(id) as cheshu,sum(maozhong) as maozhong,sum(pizhong) as pizhong,sum(kouzhong) as kouzhong,sum(jingzhong) as jingzhong,sum(fahuozhongliang) as fahuozhongliang,sum(jisuanfangliang) as jisuanfangliang";
                groupCols = "wuliaomingcheng,xinghao,zhandian";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}出库日统计】\n", kaiShiDate.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }
            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("今日出库异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event21Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "出库物料", "", SearchConditionType.等于);
                DateTime kaiShiDate = DateTime.Today;
                DateTime jieShuDate = kaiShiDate.AddHours(23).AddMinutes(59).AddSeconds(59);
                createCondition += m_DB.CreateAndCondition("maozhongshijian", DataValueCommonType.日期时间, kaiShiDate.ToString("yyyy-MM-dd HH:mm:ss"), jieShuDate.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "wuliaomingcheng,xinghao,zhandian,count(id) as cheshu,sum(maozhong) as maozhong,sum(pizhong) as pizhong,sum(kouzhong) as kouzhong,sum(jingzhong) as jingzhong,sum(fahuozhongliang) as fahuozhongliang,sum(jisuanfangliang) as jisuanfangliang";
                groupCols = "wuliaomingcheng,xinghao,zhandian";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}出库日统计】\n", kaiShiDate.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }
            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("今日出库异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event22Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "出库物料", "", SearchConditionType.等于);
                DateTime today = DateTime.Today;
                DateTime kaiShiDate = new DateTime(today.Year, today.Month, 1);
                DateTime jieShuDate = today.AddHours(23).AddMinutes(59).AddSeconds(59);
                createCondition += m_DB.CreateAndCondition("maozhongshijian", DataValueCommonType.日期时间, kaiShiDate.ToString("yyyy-MM-dd HH:mm:ss"), jieShuDate.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "wuliaomingcheng,xinghao,zhandian,count(id) as cheshu,sum(maozhong) as maozhong,sum(pizhong) as pizhong,sum(kouzhong) as kouzhong,sum(jingzhong) as jingzhong,sum(fahuozhongliang) as fahuozhongliang,sum(jisuanfangliang) as jisuanfangliang";
                groupCols = "wuliaomingcheng,xinghao,zhandian";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}出库月统计】\n", kaiShiDate.ToString("yyyy-MM")));
                    string tmpZhanDian = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        }
                        else
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                            strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                            tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        }
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }
                
            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("本月出库异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event31Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "入库物料", "", SearchConditionType.等于);
                DateTime today = DateTime.Today;
                createCondition += m_DB.CreateAndCondition("pizhongshijian", DataValueCommonType.日期时间, today.ToString("yyyy-MM-dd 00:00:00"), today.ToString("yyyy-MM-dd 23:59:59"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("danweimingcheng", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                tableCols = "zhandian,danweimingcheng,wuliaomingcheng,xinghao,sum(jingzhong) as jingzhong";
                groupCols = "zhandian,danweimingcheng,wuliaomingcheng,xinghao";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}入库供应商统计】\n", today.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    string tmpDanWeiMingCheng = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (!row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                        }
                        if (!row["danweimingcheng"].Equals(tmpDanWeiMingCheng))
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["danweimingcheng"]));
                        }

                        strBuilder.Append(string.Format("{0} {1}\n{2}吨\n", row["wuliaomingcheng"], row["xinghao"], row["jingzhong"]));
                        tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        tmpDanWeiMingCheng = string.Format("{0}", row["danweimingcheng"]);
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }

            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("本日供应商统计异常：{0}", err.Message));
                return string.Empty;
            }
        }

        public string Event32Handler(BaseDataBase m_DB)
        {
            try
            {
                string createCondition = m_DB.CreateAndCondition("chengzhongleixing", DataValueCommonType.字符串, "入库物料", "", SearchConditionType.等于);
                DateTime today = DateTime.Today;
                createCondition += m_DB.CreateAndCondition("pizhongshijian", DataValueCommonType.日期时间, today.ToString("yyyy-MM-dd 00:00:00"), today.ToString("yyyy-MM-dd 23:59:59"), SearchConditionType.between);
                string tableCols = string.Empty;
                string groupCols = string.Empty;
                Dictionary<string, string> orderBy = new Dictionary<string, string>();
                orderBy.Add("zhandian", "asc");
                orderBy.Add("danweimingcheng", "asc");
                orderBy.Add("wuliaomingcheng", "asc");
                orderBy.Add("xinghao", "asc");
                orderBy.Add("chepaihao", "asc");
                tableCols = "zhandian,danweimingcheng,chepaihao,wuliaomingcheng,xinghao,sum(jingzhong) as jingzhong,count(id) as cheshu";
                groupCols = "zhandian,danweimingcheng,chepaihao,wuliaomingcheng,xinghao";
                DataTable Dt = m_DB.GetDataTableByCondition("tbl_chengzhong", tableCols, null, createCondition, groupCols, orderBy);
                StringBuilder strBuilder = new StringBuilder();
                if (Dt.Rows.Count > 0)
                {
                    strBuilder.Append(string.Format("【{0}入库车辆统计】\n", today.ToString("yyyy-MM-dd")));
                    string tmpZhanDian = string.Empty;
                    string tmpDanWeiMingCheng = string.Empty;
                    foreach (DataRow row in Dt.Rows)
                    {
                        if (!row["zhandian"].Equals(tmpZhanDian))
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["zhandian"]));
                        }
                        if (!row["danweimingcheng"].Equals(tmpDanWeiMingCheng))
                        {
                            strBuilder.Append(string.Format("【{0}】\n", row["danweimingcheng"]));
                        }

                        strBuilder.Append(string.Format("{0} {1}\n{2}吨 {3}车\n", row["chepaihao"], row["xinghao"], row["jingzhong"],row["cheshu"]));
                        tmpZhanDian = string.Format("{0}", row["zhandian"]);
                        tmpDanWeiMingCheng = string.Format("{0}", row["danweimingcheng"]);
                    }
                    return strBuilder.ToString();
                }
                else
                {
                    return "【没有数据】";
                }

            }
            catch (Exception err)
            {
                KeaoUtils.LogTxt(string.Format("本日车辆统计异常：{0}", err.Message));
                return string.Empty;
            }
        }

    }
}